package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 服务订单
 * </p>
 *
 * @author dq
 * @date 2022-10-17
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ServiceOrderWorkOrderStatusEnum", description = "工单状态 #{NOT_DISPATCH:未派单;HAS_DISPATCH:已派单;HAS_RECEIVE:已接单;PARTIAL_COMPLETE:部分完成;COMPLETE:已完成-枚举")
public enum WorkOvertimeWorkOrderStatusEnum implements BaseEnum {

    /**
     * NOT_DISPATCH="未派单"
     */
    NOT_DISPATCH("未派单"),
    /**
     * HAS_DISPATCH="已派单"
     */
    HAS_DISPATCH("已派单"),
    /**
     * HAS_RECEIVE="已接单"
     */
    HAS_RECEIVE("已接单"),
    /**
     * PARTIAL_COMPLETE="部分完成"
     */
    PARTIAL_COMPLETE("部分完成"),
    /**
     * COMPLETE="已完成"
     */
    COMPLETE("已完成"),
    /**
     * CANCEL="已取消"
     */
    CANCEL("已取消"),
    /**
     * REVOKE="已撤销"
     */
    REVOKE("已撤销"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static WorkOvertimeWorkOrderStatusEnum match(String val, WorkOvertimeWorkOrderStatusEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static WorkOvertimeWorkOrderStatusEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(WorkOvertimeWorkOrderStatusEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "NOT_DISPATCH,HAS_DISPATCH,HAS_RECEIVE,PARTIAL_COMPLETE,COMPLETE", example = "NOT_DISPATCH")
    public String getCode() {
        return this.name();
    }

}
